type EventHandler = (e: Event) => void;
type EventHandler2 = {
    (e: Event): void
}

const btn = new HTMLButtonElement()

function addListener(el: Element, handler: { (e: Event): void }) { }
// function addListener(el: Element, handler: (e: Event) => void) { }

// function addListener(el:Element,handler:EventHandler) {}
// function addListener(el:Element,handler:EventHandler2) {}

addListener(btn, e => { })




/* 函数重载 */
function sayHello(who: string): void;
function sayHello(who: Object): void;

function sayHello(who: string | Object): void {
    if (typeof who === "string") {
        console.log(`hello ${who}`);
        return
    }

    if (typeof who === "object") {
        console.log(`hello ${JSON.stringify(who)}`);
        return
    }
}

sayHello("张三")
sayHello({ name: '张三' })